<?php
/*
 * Created on 11-Jul-2006
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */



    // adds shared resource pages to other pages

    require_once("module_resourcepage.php");
    $module=module_resourcepage::$inst;
 
    // pick up the stuff that is to added
    // Resourcepage, course and container id's of resourcepage to be added
    $shareable = required_param('shareable',PARAM_SEQUENCE);
    list($resourcepageid, $courseid, $containerid) = explode(',', $shareable);
    if (empty($resourcepageid) || empty($courseid) || empty($containerid)) {
        $error = required_param('shared_resource',PARAM_INT);
    }

    // pick up the stuff that requires adding to
    $id=required_param('id',PARAM_INT);                             // Course Module ID of the stuff to be added to

    $sesskey=required_param('sesskey',PARAM_ALPHA);                 // session key

    $module->obtain_view_info($id,null,$cm,$course,$resourcepage);

    // Security checks
    $module->verify_edit_action($cm);

    // pick up the details of the stuff needing to be added to
    $rpid = $cm->instance;
    $cid = $cm->course;
    $ctid = $resourcepage->containerid;

    // add the shared resourcepage to the sharing resourcepage
    $module->add_container_subcontainer($ctid,$containerid);

    // return to main course view

    // Log and return to view
    add_to_log($course->id, "resourcepage", "addshared", "view.php?id=$id",
        "Added shared page".$resourcepageid);

    redirect('view.php?id='.$id);
?>